package br.senai.sc.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

/**
 * @author Fernando Marquardt &lt;fernando.marquardt@sc.senai.br&gt;
 * @since 01/02/2012
 * @version $Id: CondicaoClimatica.java 28 2012-03-07 20:48:20Z fernando.marquardt $
 */
@Entity
@Table(name = "condicao_climatica")
@NamedQuery(name = CondicaoClimatica.CONDICOES_CLIMATICAS, query = "SELECT cc FROM CondicaoClimatica cc ORDER BY cc.nome")
public class CondicaoClimatica implements Serializable {

    private static final long serialVersionUID = 1L;

    public static final String CONDICOES_CLIMATICAS = "CONDICOES_CLIMATICAS";

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id_condicao_climatica")
    private Integer idCondicaoClimatica;

    @NotBlank
    @Length(max = 150)
    private String nome;

    public CondicaoClimatica() {}

    public Integer getIdCondicaoClimatica() {
        return idCondicaoClimatica;
    }

    public void setIdCondicaoClimatica(Integer idCondicaoClimatica) {
        this.idCondicaoClimatica = idCondicaoClimatica;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    @Override
    public String toString() {
        return "CondicaoClimatica [idCondicaoClimatica=" + idCondicaoClimatica + ", nome=" + nome + "]";
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((nome == null) ? 0 : nome.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        CondicaoClimatica other = (CondicaoClimatica) obj;
        if (nome == null) {
            if (other.nome != null) {
                return false;
            }
        } else if (!nome.equals(other.nome)) {
            return false;
        }
        return true;
    }
}